Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add url config validation #5578

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

ShaytonXu
Copy link

@ShaytonXu ShaytonXu commented Nov 30, 2024

What does it do?

Add url config validation.
To resolve the issue. #5577

Screenshots

Pull request tasks

  • Add test cases for the changes.
  • Passed the CI test.

Copy link

How to test

git clone -b feature/add-config-url-validation https://github.com/XuXianTao/hexo.git
cd hexo
npm install
npm test

Copy link
Member

@SukkaW SukkaW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Idea LGTM, only a few questions.

@@ -12,6 +12,8 @@ export = (ctx: Hexo): void => {
try {
// eslint-disable-next-line no-new
new URL(config.url);
// eslint-disable-next-line no-new
new URL('source/_post/xxx', config.url);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe change source/_post/xxx to config.root, config.permalink, or something similar?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a good idea, but I think it will fail because of wrong config.root or config.permalink, not like the error description Invalid config detected: "url" should be a valid URL!.

I think config.root, config.permalink should be check in other part. And the config.root is already checked after this.

So, I think a simple string variable may be better.

@ShaytonXu ShaytonXu requested a review from SukkaW December 2, 2024 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants